---
title: "不透明度"
# description: "Utilities for controlling the opacity of an element."
description: "用于控制元素不透明度的功能类。"
features:
  responsive: true
  customizable: true
  hover: false
  focus: false
---

import plugin from 'tailwindcss/lib/plugins/opacity'
import { Variants } from '@/components/Variants'
import { Disabling } from '@/components/Disabling'

export const classes = { plugin }

<!-- ## Usage -->
## 使用

<!-- Control the opacity of an element using the `opacity-{amount}` utilities. -->
使用 `opacity-{amount}` 功能控制元素的不透明度。

```html lightBlue
<template preview>
  <div class="grid grid-cols-2 gap-2 sm:grid-cols-5">
    <div class="h-16 rounded-md opacity-100 bg-light-blue-600 font-extrabold text-white flex justify-center items-center">100%</div>
    <div class="h-16 rounded-md opacity-75 bg-light-blue-600 font-extrabold text-white flex justify-center items-center">75%</div>
    <div class="h-16 rounded-md opacity-50 bg-light-blue-600 font-extrabold text-white flex justify-center items-center">50%</div>
    <div class="h-16 rounded-md opacity-25 bg-light-blue-600 font-extrabold text-white flex justify-center items-center">25%</div>
    <div class="h-16 rounded-md opacity-0 bg-light-blue-600 font-extrabold text-white flex justify-center items-center">0%</div>
  </div>
</template>

<div class="bg-light-blue-600 **opacity-100** ..."></div>
<div class="bg-light-blue-600 **opacity-75** ..."></div>
<div class="bg-light-blue-600 **opacity-50** ..."></div>
<div class="bg-light-blue-600 **opacity-25** ..."></div>
<div class="bg-light-blue-600 **opacity-0** ..."></div>
```

<!-- ## Responsive -->
## 响应式

<!-- To control the opacity of an element at a specific breakpoint, add a `{screen}:` prefix to any existing opacity utility. For example, use `md:opacity-50` to apply the `opacity-50` utility at only medium screen sizes and above. -->
要在特定的断点处控制元素的不透明度，可在任何现有的不透明度功能中添加 `{screen}:` 前缀。例如，使用 `md:opacity-50` 来应用 `opacity-50` 功能，只适用于中等大小的屏幕及以上。

```html
<div class="opacity-100 **md:opacity-50** ...">
  <!-- ... -->
</div>
```

<!-- For more information about Tailwind's responsive design features, check out the [Responsive Design](/docs/responsive-design) documentation. -->
关于 Tailwind 的响应式设计功能的更多信息，请查看[响应式设计](/docs/responsive-design)文档。

<!-- ## Customizing -->
## 自定义

### Opacity Scale

<!-- By default Tailwind provides five opacity utilities based on a simple numeric scale. You change, add, or remove these by editing the `theme.opacity` section of your Tailwind config. -->
默认情况下，Tailwind 提供了五个基于简单的数字比例的不透明度功能。您可以通过编辑您的 Tailwind 配置中的 `theme.opacity` 部分来改变，添加或删除这些功能。

```diff-js
  // tailwind.config.js
  module.exports = {
    theme: {
      opacity: {
        '0': '0',
-       '25': '.25',
-       '50': '.5',
-       '75': '.75',
+       '10': '.1',
+       '20': '.2',
+       '30': '.3',
+       '40': '.4',
+       '50': '.5',
+       '60': '.6',
+       '70': '.7',
+       '80': '.8',
+       '90': '.9',
        '100': '1',
      }
    }
  }
```

<!-- ### Variants -->
### 变体

<Variants plugin="opacity" />

<!-- ### Disabling -->
### 禁用

<Disabling plugin="opacity" />
